package com.example.azheng.okhttpdemo.utils;


import com.example.azheng.okhttpdemo.base.BaseApplication;



import java.util.Objects;

import io.rx_cache2.internal.RxCache;
import io.victoralbertos.jolyglot.GsonSpeaker;

public class CacheProviders {

    private static volatile CacheProvidersApi instance;
    private CacheProviders() {

    }
    public static CacheProvidersApi getInstance() {
        if (instance == null) {
            synchronized (CacheProviders.class) {
                if (instance == null) {
                    instance = new RxCache.Builder()
                            //缓存文件的配置、数据的解析配置
                            .persistence(Objects.requireNonNull(BaseApplication.getApplication().getExternalCacheDir()), new GsonSpeaker())
                            //这些配置对应的缓存接口
                            .using(CacheProvidersApi.class);
                }
            }

        }
        return instance;
    }



}

